package com.tapstitch.scm.common.utils;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.Map;

public class MapBuilderUtil {

	public static <K, V> MapBuilder<K, V> put(K k, V v) {
		return new MapBuilder<K, V>(k, v);
	}

	public static class MapBuilder<K, V> {

		private Map<K, V> map = new HashMap<>();

		MapBuilder(K k, V v) {
			map.put(k, v);
		}

		public MapBuilder<K, V> put(K k, V v) {
			map.put(k, v);
			return this;
		}

		public Map<K, V> build() {
			return map;
		}

		public String toJsonString() {
			return JSON.toJSONString(map);
		}
	}
}
